-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: set cache header for non-immutable build assets #14483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: set cache header for non-immutable build assets #14483
Conversation
When serving client files, ensure non-immutable assets are never cached by browsers by setting no-cache,no-store header
🦋 Changeset detectedLatest commit: 46c5757 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Only static assets should be cached immutably. All other assets should revalidate to ensure freshness.
Browsers don't generally cache by default, but from a quick glance it looks like the may use a heuristic to decide such as file extension and may possibly cache. Would probably be good to find a more authoritative reference If this is an issue, I would guess it's not unique to adapter-node and should be fixed everywhere |
Yes, they follow https://datatracker.ietf.org/doc/html/rfc7234#section-4.2.2 and at least for cases I have seen those files are cached. They actually do it based on 200 responses in general when there is a last-modified header:
|
I've always wanted to check if |
When serving client files, ensure non-immutable assets are never cached by browsers by setting a maxage=0 cache header.
When no
cache-control
header is set, browsers will still cache files and with/_app/version.json
and/_app/env.js
this causes a lot of issues when deploying new versions using the node adapter.Similiar to what is done here https://github.com/sveltejs/kit/blob/main/packages/kit/src/runtime/server/respond.js#L291-L294
fixes #9089
fixes #13799
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits